package com.ocom.human.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ocom.common.entity.master.EntityMngUserDock;
import com.ocom.common.enums.DataSourceEnum;
import com.ocom.human.dao.IDaoMngUserDock;
import com.ocom.human.service.MngUserDockService;
import com.ocom.mysql.aspect.DataSourceAspect;
import org.springframework.stereotype.Service;

@Service
public class MngUserDockServiceImpl extends ServiceImpl<IDaoMngUserDock, EntityMngUserDock> implements MngUserDockService {


    @DataSourceAspect(type = DataSourceEnum.MAIN_DB)
    @Override
    public EntityMngUserDock findByComIdAndUserIdAndDockCode(Long comId, Long userId, String dockCode) {
        QueryWrapper<EntityMngUserDock> queryWrapper = Wrappers.query();
        queryWrapper.eq("com_id", comId);
        queryWrapper.eq("user_id", userId);
        queryWrapper.eq("dock_code", dockCode);
        queryWrapper.last("limit 1");
        return this.getOne(queryWrapper);
    }
}
